package cn.xsly._01;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

import static java.nio.charset.StandardCharsets.UTF_8;

public class Productor {
    public static void main(String[] args) throws Exception{
        DefaultMQProducer producer = new DefaultMQProducer("sync_producer_group");
        producer.setNamesrvAddr("127.0.0.1:9876");
        producer.start();
        Message message = new Message("sync_order","pet","我在床上学习".getBytes(RemotingHelper.DEFAULT_CHARSET));
        SendResult sendResult = producer.send(message);
        // 4.3.打印消息发送结果
        System.out.println(sendResult);
        // 5.关闭生产者
        producer.shutdown();
    }
}
